#include <iostream>
#include <cstdio>
using namespace std;

class Time
{
public:
	Time(int h,int m,int s)
	{
		hour=h;
		minute=m;
		second=s;
	}
	void set(int h, int m,int s)
	{
		hour=h;
		minute=m;
		second=s;
	}
	void increment();
	void display();
	bool equal(const Time &other_time) const;
	bool less_than(const Time &other_time) const;
protected:
	int hour;
	int minute;
	int second;
};


void Time::increment()
{
		second++;
		if(second==60)
		{
			second=0;
			minute++;
			if(minute==60)
			{
				minute=0;
				hour++;
			}
		}

}
void Time::display()
{
	cout<<hour<<":"<<minute<<":"<<second<<endl;
}

bool Time::equal(const Time &other_time) const
{
	
	if(other_time.hour==hour&&other_time.minute==minute&&other_time.second==second)
		return true;
	else
		return false;
}

bool Time::less_than(const Time &other_time) const
{
	if(hour<other_time.hour)
		return true;
	else if(hour==other_time.hour&&minute<other_time.minute)
		return true;
	else if(hour==other_time.hour&&minute==other_time.minute&&second<other_time.second)
		return true;
	else 
		return false;

}

class Date
{
public:
	Date(int y,int m,int d)
	{
		year=y;
	    month=m;
	    day=d;
	}
	void set(int y,int m,int d);
	bool equal(const Date &date2) const ;
	bool less_than(const Date &date2) const;
	void increment();
	void display();
protected:
	int year;
	int month;
	int day;
};

void Date::set(int y,int m,int d)
{
	year=y;
	month=m;
	day=d;
}

void Date::increment()
{
	day++;
	if((year%4==0&&year%100!=0)||(year%100==0))
	{
	if(day==30&&month==2)
	{month++; day=1;}
	if(day==32&&(month==1||month==3||month==5||month==7||month==8||month==10))
	{month++;day=1;}
	if(day==31&&(month==4||month==6||month==9||month==11))
	{month++;day=1;}
	if(day==32&&month==12)
	{year++;month=1;day=1;}
	}
	else
	{
	if(day==29&&month==2)
	{month++; day=1;}
	if(day==32&&(month==1||month==3||month==5||month==7||month==8||month==10))
	{month++;day=1;}
	if(day==31&&(month==4||month==6||month==9||month==11))
	{month++;day=1;}
	if(day==32&&month==12)
	{year++;month=1;day=1;}
	}
}
bool Date::equal(const Date &date2) const  
{ 
	return year == date2.year && month == date2.month && day == date2.day;
}  

bool Date::less_than(const Date &date2) const 
{ 
	if (year < date2.year || year == date2.year && month < date2.month||year == date2.year && month == date2.month && day < date2.day)
        return true; 
	else 
		return false; 
 } 
void Date::display()
{
	cout<<year<<"-"<<month<<"-"<<day<<endl;
}

class TimeWithDate:public Time,public Date
{
public:
	TimeWithDate(int y,int mon,int d,int h,int min,int s):Date(y,mon,d),Time(h,min,s){}
	bool equal(const TimeWithDate &td2) const;  
	bool less_than(const TimeWithDate &td2) const;
	void increment();  
	int difference(const TimeWithDate & td2) const;
	void display() ; 
}; 
bool TimeWithDate::equal(const TimeWithDate &td2) const
{ 
	return Time::equal(td2) && Date::equal(td2); 
}  

bool TimeWithDate::less_than(const TimeWithDate &td2) const
{ 
	if (Date::less_than(td2)) 
		return true;  
	else if (Date::equal(td2) && Time::less_than(td2))
		return true; 
	else  
		return false; 
}  

void TimeWithDate::increment() 

{ 
	Time::increment();  
	if (hour == 0 && minute == 0 && second == 0) 
    Date::increment(); 
}  

int TimeWithDate::difference(const TimeWithDate &td2) const
{ 
	int days=0;  
	if (less_than(td2))
	{
		for (TimeWithDate td=*this; td.less_than(td2); td.increment()) 
			days--; 
	}
	else 
	{
		for (TimeWithDate td=td2; td.less_than(*this); td.increment()) 
			days++; 
	}
	return days; 
}  

void TimeWithDate::display() 
{ 
	Date::display(); 
	cout << ' ';  
	Time::display(); 

}  

int main()
{
	TimeWithDate td1(2014,5,4,20,55,15);
	TimeWithDate td2(2014,5,4,20,55,20);
	int a=td1.difference(td2);
	cout<<a<<endl;
	td1.display();
	td2.display();
	return 0;
}




